package main

import (
	"fmt"
	"github.com/astaxie/beego/toolbox"
	"month_zh5/common/model/es"
	"month_zh5/common/model/mysql"
	"month_zh5/common/nacos"
	"month_zh5/common/viper_config"
	"strconv"
)

func main() {
	tk1 := toolbox.NewTask("tk1", "0 0 0 * * *", func() error {
		config := viper_config.ViperConfig("server", "./config", "Nacos")
		nacos.NewNaCos(config["ipaddr"], config["dataid"], config["group"])
		fmt.Println(config, nacos.NacosConfig)
		mysql.InitMysql()
		es.InitEs()
		all := mysql.WhereAll()
		for _, goods := range all {
			err2 := es.Create(goods, "goods", strconv.Itoa(int(goods.ID)))
			if err2 != nil {
				return err2
			}
		}
		return nil
	})
	tk1.Run()
	toolbox.AddTask("tk1", tk1)
	toolbox.StartTask()
	defer toolbox.StopTask()
}
